home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / src / pltick.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-30  |  4.0 KB  |  154 lines

  1. /* $Id: pltick.c,v 1.6 1994/06/30 18:22:22 mjl Exp $
  2.  * $Log: pltick.c,v $
  3.  * Revision 1.6  1994/06/30  18:22:22  mjl
  4.  * All core source files: made another pass to eliminate warnings when using
  5.  * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
  6.  * (now included by plplot.h), and other minor changes.  Now each file has
  7.  * global access to the plstream pointer via extern; many accessor functions
  8.  * eliminated as a result.
  9.  *
  10.  * Revision 1.5  1994/03/23  08:35:11  mjl
  11.  * All external API source files: replaced call to plexit() on simple
  12.  * (recoverable) errors with simply printing the error message (via
  13.  * plabort()) and returning.  Should help avoid loss of computer time in some
  14.  * critical circumstances (during a long batch run, for example).
  15. */
  16.  
  17. /*    pltick.c
  18.  
  19.     Routines for drawing error bars and tick marks.
  20. */
  21.  
  22. #include "plplotP.h"
  23.  
  24. /*----------------------------------------------------------------------*\
  25.  * void plxtik()
  26.  *
  27.  * Draws a tick parallel to x.
  28. \*----------------------------------------------------------------------*/
  29.  
  30. void
  31. plxtik(PLINT x, PLINT y, PLINT below, PLINT above)
  32. {
  33.     plP_draphy(x, y);
  34.  
  35.     if (below != 0)
  36.     plP_draphy(x, y - below);
  37.  
  38.     if (above != 0)
  39.     plP_draphy(x, y + above);
  40.  
  41.     plP_draphy(x, y);
  42. }
  43.  
  44. /*----------------------------------------------------------------------*\
  45.  * void plytik()
  46.  *
  47.  * Draws a tick parallel to y.
  48. \*----------------------------------------------------------------------*/
  49.  
  50. void
  51. plytik(PLINT x, PLINT y, PLINT left, PLINT right)
  52. {
  53.     plP_draphy(x, y);
  54.  
  55.     if (left != 0)
  56.     plP_draphy(x - left, y);
  57.  
  58.     if (right != 0)
  59.     plP_draphy(x + right, y);
  60.  
  61.     plP_draphy(x, y);
  62. }
  63.  
  64. /*----------------------------------------------------------------------*\
  65.  * void plstik()
  66.  *
  67.  * Draws a slanting tick at position (mx,my) (measured in mm) of
  68.  * vector length (dx,dy).
  69. \*----------------------------------------------------------------------*/
  70.  
  71. void 
  72. plstik(PLFLT mx, PLFLT my, PLFLT dx, PLFLT dy)
  73. {
  74.     plP_draphy(plP_mmpcx(mx), plP_mmpcy(my));
  75.     plP_draphy(plP_mmpcx((PLFLT) (mx + dx)), plP_mmpcy((PLFLT) (my + dy)));
  76.     plP_draphy(plP_mmpcx(mx), plP_mmpcy(my));
  77. }
  78.  
  79. /*----------------------------------------------------------------------*\
  80.  * void plerx1()
  81.  *
  82.  * Plot single horizontal error bar.
  83. \*----------------------------------------------------------------------*/
  84.  
  85. static void
  86. plerx1(PLFLT xmin, PLFLT xmax, PLFLT y)
  87. {
  88.     PLINT yminor;
  89.  
  90.     yminor = MAX(1.0, plsc->minht * plsc->ypmm);
  91.     plP_movwor(xmin, y);
  92.     plxtik(plP_wcpcx(xmin), plP_wcpcy(y), yminor, yminor);
  93.     plP_drawor(xmax, y);
  94.     plxtik(plP_wcpcx(xmax), plP_wcpcy(y), yminor, yminor);
  95. }
  96.  
  97. /*----------------------------------------------------------------------*\
  98.  * void plery1()
  99.  *
  100.  * Plot single vertical error bar.
  101. \*----------------------------------------------------------------------*/
  102.  
  103. static void
  104. plery1(PLFLT x, PLFLT ymin, PLFLT ymax)
  105. {
  106.     PLINT xminor;
  107.  
  108.     xminor = MAX(1.0, plsc->minht * plsc->xpmm);
  109.     plP_movwor(x, ymin);
  110.     plytik(plP_wcpcx(x), plP_wcpcy(ymin), xminor, xminor);
  111.     plP_drawor(x, ymax);
  112.     plytik(plP_wcpcx(x), plP_wcpcy(ymax), xminor, xminor);
  113. }
  114.  
  115. /*----------------------------------------------------------------------*\
  116.  * void plerrx()
  117.  *
  118.  * Plot horizontal error bars (xmin(i),y(i)) to (xmax(i),y(i)).
  119. \*----------------------------------------------------------------------*/
  120.  
  121. void
  122. c_plerrx(PLINT n, PLFLT *xmin, PLFLT *xmax, PLFLT *y)
  123. {
  124.     PLINT i;
  125.  
  126.     if (plsc->level < 3) {
  127.     plabort("plerrx: Please set up window first");
  128.     return;
  129.     }
  130.  
  131.     for (i = 0; i < n; i++)
  132.     plerx1(xmin[i], xmax[i], y[i]);
  133. }
  134.  
  135. /*----------------------------------------------------------------------*\
  136.  * void plerry()
  137.  *
  138.  * Plot vertical error bars (x,ymin(i)) to (x(i),ymax(i)).
  139. \*----------------------------------------------------------------------*/
  140.  
  141. void
  142. c_plerry(PLINT n, PLFLT *x, PLFLT *ymin, PLFLT *ymax)
  143. {
  144.     PLINT i;
  145.  
  146.     if (plsc->level < 3) {
  147.     plabort("plerry: Please set up window first");
  148.     return;
  149.     }
  150.  
  151.     for (i = 0; i < n; i++)
  152.     plery1(x[i], ymin[i], ymax[i]);
  153. }
  154.